SWAMEE_JAIN

Overview

The SWAMEE_JAIN function calculates the Darcy friction factor for turbulent flow in pipes using the Swamee-Jain (1976) explicit equation. This correlation provides a direct, non-iterative solution that approximates the implicit Colebrook-White equation, which is the industry standard for friction factor calculations in pipe flow.

The Darcy friction factor is a dimensionless quantity used in the Darcy-Weisbach equation to calculate pressure drop and head loss due to friction in pipe systems. The Colebrook-White equation requires iterative solution methods, making the Swamee-Jain approximation particularly useful for spreadsheet applications and situations requiring rapid computation.

This implementation uses the fluids Python library. For full documentation, see the fluids.friction module.

The Swamee-Jain equation is expressed as:

\frac{1}{\sqrt{f}} = -4 \log_{10}\left[\left(\frac{6.97}{Re}\right)^{0.9} + \frac{\varepsilon}{3.7D}\right]

where f is the Darcy friction factor, Re is the Reynolds number, and \varepsilon/D is the relative roughness (pipe roughness divided by pipe diameter).

The equation is valid for Reynolds numbers between 5 \times 10^3 and 10^8, and relative roughness values between 10^{-6} and 5 \times 10^{-2}. Within this range, the Swamee-Jain approximation matches the Colebrook-White equation to within about 1% accuracy, which is well within the uncertainty of experimental friction factor data.

Reference: Swamee, P.K., and Jain, A.K. “Explicit Equations for Pipe-Flow Problems.” Journal of the Hydraulics Division 102, no. 5 (May 1976): 657-664. doi:10.1061/JYCEAJ.0004542

This example function is provided as-is without any representation of accuracy.

Excel Usage

=SWAMEE_JAIN(Re, eD)
  • Re (float, required): Reynolds number, [-]
  • eD (float, required): Relative roughness (roughness/diameter), [-]

Returns (float): Darcy friction factor, [-] str: Error message if inputs are invalid.

Examples

Example 1: Smooth pipe with low Reynolds number

Inputs:

Re eD
10000 0.000001

Excel formula:

=SWAMEE_JAIN(10000, 0.000001)

Expected output:

0.0309

Example 2: Smooth pipe with high Reynolds number

Inputs:

Re eD
100000 0.0001

Excel formula:

=SWAMEE_JAIN(100000, 0.0001)

Expected output:

0.0185

Example 3: Rough pipe

Inputs:

Re eD
50000 0.01

Excel formula:

=SWAMEE_JAIN(50000, 0.01)

Expected output:

0.0381

Example 4: Very rough pipe at upper eD limit

Inputs:

Re eD
1000000 0.05

Excel formula:

=SWAMEE_JAIN(1000000, 0.05)

Expected output:

0.0718

Python Code

import micropip
await micropip.install(["fluids"])
from fluids.friction import Swamee_Jain_1976 as fluids_swamee_jain

def swamee_jain(Re, eD):
    """
    Calculate Darcy friction factor using the Swamee-Jain (1976) equation.

    See: https://fluids.readthedocs.io/fluids.friction.html#fluids.friction.Swamee_Jain_1976

    This example function is provided as-is without any representation of accuracy.

    Args:
        Re (float): Reynolds number, [-]
        eD (float): Relative roughness (roughness/diameter), [-]

    Returns:
        float: Darcy friction factor, [-] str: Error message if inputs are invalid.
    """
    try:
        Re = float(Re)
        eD = float(eD)
    except (ValueError, TypeError):
        return "Error: Could not convert parameters to required types."

    # Validate Reynolds number
    if Re <= 0:
        return "Error: Reynolds number must be positive."

    # Validate relative roughness
    if eD < 0:
        return "Error: Relative roughness must be non-negative."

    try:
        result = fluids_swamee_jain(Re=Re, eD=eD)

        # Handle NaN and infinity
        if result != result:  # NaN check
            return "nan"
        if result == float('inf'):
            return "inf"
        if result == float('-inf'):
            return "-inf"

        return float(result)
    except Exception as e:
        return f"Error computing swamee_jain: {str(e)}"

Online Calculator